<template>
  <h1>测试</h1>
  <h2>{{ name }} {{ age }}</h2>
  <button @click="handleClick">增加年龄</button>
  <button @click="handleClick2">增加年龄用action</button>
  <button @click="handleReset">重置年龄</button>
  <div>getter后的num {{ changeAge }}</div>
</template>

<script setup>
import {useStore} from '../store/index.js'
import {storeToRefs} from "pinia";
import {$emit,EVENT_TYPE} from '@/utils/mitt'
const store = useStore()
const {name, age, changeAge} = storeToRefs(store)
const {incrementAge} = store
console.log('store', store, name, age)

function handleClick() {
  $emit(EVENT_TYPE.CLICK, age.value)
  name.value = '阮景涛'
  age.value++
}


function handleReset() {
  store.$reset()
}

function handleClick2() {
  incrementAge()
}
</script>

<style scoped>

</style>
